Skip to content

Make NoneType annotation error a new code#20222

Merged
hauntsaninja merged 4 commits intopython:masterfrom
wyattscarpenter:nonetype-code
Nov 28, 2025
Merged

Make NoneType annotation error a new code#20222
hauntsaninja merged 4 commits intopython:masterfrom
wyattscarpenter:nonetype-code

Conversation

@wyattscarpenter
Copy link
Copy Markdown
Contributor

Change the code of "NoneType should not be used as a type, please use None instead" error to be a new code, so that people who don't like this rule can disable it easily.

I haven't made this a subcode of valid-type because NoneType is actually a valid type; it's just dispreferred.

I have added the documentation for the new code, but haven't added any new tests (the old test still runs fine).

Fixes #20218

Comment thread docs/source/error_code_list.rst
@github-actions

This comment has been minimized.

wyattscarpenter and others added 2 commits November 11, 2025 16:50
Change the code of "NoneType should not be used as a type, please use None instead" error to be a new code, so that people who don't like this rule can disable it easily.

I haven't made this a subcode of valid-type because NoneType is actually a valid type; it's just dispreferred.

I have added the documentation for the new code, but haven't added any new tests (the old test still runs fine).

Fixes python#20218
Comment thread docs/source/error_code_list.rst Outdated
Comment thread mypy/errorcodes.py
Co-authored-by: A5rocks <git@helvetica.moe>
@github-actions
Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja merged commit a7e477f into python:master Nov 28, 2025
22 checks passed
@wyattscarpenter wyattscarpenter deleted the nonetype-code branch November 28, 2025 22:50
@github-project-automation github-project-automation bot moved this from Todo to Done in GC-Content-Calculator Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The object None works but the type NoneType doesn't work

4 participants